{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  {if $doSubmit == 1}
    bookFunction();
  {/if}
});

function deleteRow(vepaariBookDetailId)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway.") && confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "vepaaribillDelete.php?vepaariBookDetailId="+vepaariBookDetailId;
  }
}
function bookFunction(id)
{
  document.form1.bdate.value="1";
  document.form1.submit();
  form1.submitit.disabled=true;
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>{$l_kaarigarDetail}</h4></center>
<div class="contentDiv">
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="4">
    <tr><hr/></tr>  
		 <tr>
		  <td colspan="4" class="table1">
		    {$l_kaarigarName} :
		    <select name="kaarigarId">
		      <option value="0">{$l_kaarigarName}</option>
		      {html_options values=$kaarigar.id output=$kaarigar.name selected={$kaarigarId}}
		    </select>
		  </td>
		  <td colspan="5" class="table1">
		  	{if $doSubmit == 1}
			    {$l_from} : 
			    {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$fromDate}}
			    {$l_to} 
			    {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$toDate}}
			  {/if}
		  </td>
		  <td class="table1"><input type="submit" name="submitBtn" value="{$l_find}" /></td>
		  <td class="table1"><a href="kaarigarDetail.php?print=1">Print</a></td>
		</tr>
	</table>	
	<table border="0" align="center" width="100%" cellspacing="0" cellpadding="4">
    <tr><hr/></tr> 
		<tr class="table1">
		  <th>&nbsp;</th>
		  <th>Parti</th>
		  <th align="right">{$l_debit}</th>
		  <th align="right">{$l_credit}</th>
		  <th align="right">{$l_vadhaaroGhataado}</th>
		  <th align="right">{$l_qty}</th>
		  <th align="right">{$l_rate}</th>
		  <th align="right">{$l_crAmount}</th>
		  <th align="right">{$l_drAmount}</th>
		  <th align="right">{$l_crDr}</th>
		</tr>
		<tr class="table2">
		  <td>&nbsp;</td>
		  <td align="right">{$opening.particulars}</td>
		  <td align="right">{if $opening.debit != 0}{$opening.debit|string_format:"%.0f"}{/if}</td>
		  <td align="right">{if $opening.credit != 0}{$opening.credit|string_format:"%.0f"}{/if}</td>
		  <td align="right">{if $opening.vadhaaroGhatado != 0}{$opening.vadhaaroGhatado|string_format:"%.0f"}{/if}</td>
		  <td align="right">{if $opening.qty != 0}{$opening.qty|string_format:"%.0f"}{/if}</td>
		  <td align="right">{if $opening.rate != 0}{$opening.rate|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="color:red;">{if $opening.crAmount != 0}{$opening.crAmount|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="color:red;>{if $opening.drAmount != 0}{$opening.drAmount|string_format:"%.0f"}{/if}</td>
		  <td align="right">{if $opening.totalAmt}{$opening.totalAmt|string_format:"%.0f"}{/if}</td>
		</tr>
		{section name="sec" loop=$kaarigarDetail|@count}
		<tr class="table2">
		  <td>
		    {if $smarty.get.print != 1}
		      <a href="#" onClick="if((confirm('Warning: Are you sure?')) && (confirm('Warning: Are you sure?')))location.href = './kaarigarDetailDelete.php?kaarigardetailId={$kaarigarDetail[sec].kaarigardetailId}';"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>
		      <a href="kaarigarEntry.php?kaarigarMasterId={$kaarigarDetail[sec].kaarigarMasterId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>
		    {else}
		      &nbsp;
		    {/if}
		  </td>
		  <td>{$kaarigarDetail[sec].kaarigarDate|date_format:"%d-%m-%Y"}&nbsp;&nbsp;{$kaarigarDetail[sec].particulars}</td>
		  <td align="right" style="border-right:1px solid;">{if $kaarigarDetail[sec].debit != 0}{$kaarigarDetail[sec].debit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid;">{if $kaarigarDetail[sec].credit != 0}{$kaarigarDetail[sec].credit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid;">{if $kaarigarDetail[sec].vadhaaroGhatado != 0 && $smarty.section.sec.index == 0}{$total.vadhGhat|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid;">{if $kaarigarDetail[sec].qty != 0}{$kaarigarDetail[sec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid;">{if $kaarigarDetail[sec].rate != 0}{$kaarigarDetail[sec].rate|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid; color:red;">{if $kaarigarDetail[sec].crAmount != 0}{$kaarigarDetail[sec].crAmount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px solid; color:green;">{if $kaarigarDetail[sec].drAmount != 0}{$kaarigarDetail[sec].drAmount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right">{if $kaarigarDetail[sec].totalAmt != 0}{$kaarigarDetail[sec].totalAmt|string_format:"%.0f"}{/if}</td>
		</tr>
		{/section}
	</table>
	<table border="0" align="center" width="100%" cellspacing="0" cellpadding="3">
    <tr><hr/></tr> 
		<tr class="table1">
		  <td>
		    {if $smarty.get.print != 1}
		    <th align="right" width="21%">{$l_total}</th>
		    <th align="right" width="25%">{$total.vadhGhat|string_format:"%.2f"}</th>
		    <th align="right" width="8.5%">{$total.qty|string_format:"%.0f"}</th>
		    <th align="right" width="18.7%">{$total.crAmount|string_format:"%.0f"}</th>
		    <th align="right">{$total.drAmount|string_format:"%.0f"}</th>
		    <th align="right" width="13%">{$total.totalAmt|string_format:"%.0f"}</th>
		    {else}
		    <th align="right" width="17%">{$l_total}</th>
		    <th align="right" width="26%">{$total.vadhGhat|string_format:"%.2f"}</th>
		    <th align="right" width="8.5%">{$total.qty|string_format:"%.0f"}</th>
		    <th align="right" width="19.5%" style="color:red;">{$total.crAmount|string_format:"%.0f"}</th>
		    <th align="right" style="color:green;">{$total.drAmount|string_format:"%.0f"}</th>
		    <th align="right" width="14%">{$total.totalAmt|string_format:"%.0f"}</th>
		    {/if}
		  </td>
		</tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
